cmake_minimum_required(VERSION 3.5)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (NOT DEFINED MS)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../build-app-Desktop_Qt_5_13_2_MSVC2017_64bit-${CMAKE_BUILD_TYPE})
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../build-app-Desktop_Qt_5_13_2_MSVC2017_64bit-${CMAKE_BUILD_TYPE})
else()
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${MS})
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MS})
endif()

project(UPDATE)
#message("xxx: ${CMAKE_CURRENT_LIST_DIR}")
set(REA2_DIR "D:/mywork3/frm/cmake")
find_package(REA2)
find_package(Qt5 COMPONENTS Core Widgets Quick REQUIRED)

set(my_Sources
    "main.cpp" #WIN32: to disable the console window
    )

set(my_Libs
    Qt5::Core Qt5::Widgets Qt5::Quick
    ${REA2_LIBS}
    )

file(GLOB PLUGINS ${CMAKE_CURRENT_SOURCE_DIR}/plugin/*)
foreach(plg ${PLUGINS})
    if (EXISTS ${plg}/CMakeLists.txt)
        include(${plg}/CMakeLists.txt)
    endif()
endforeach()

include_directories(${REA2_INCLUDE_DIRS})

add_executable(${PROJECT_NAME}
    ${my_Sources})

target_link_libraries(${PROJECT_NAME} PRIVATE ${my_Libs})
